//
//  OrderTableViewCell.m
//  CreditHub
//
//  Created by chenglang on 2024/9/14.
//

#import "OrderTableViewCell.h"
#import "WebViewController.h"

@implementation OrderTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setDicInfo:(NSDictionary *)dicInfo{
    _dicInfo = dicInfo;
    [[ImageLoader sharedInstance] loadImageFromURL:[NSURL URLWithString:dicInfo[@"roundtinker"]] imageView:self.imageViewLogo completion:^(UIImage * _Nonnull image, NSError * _Nonnull error) {
            
    }];
    
    NSArray *disgustthat = [NSArray arrayWithArray:dicInfo[@"disgustthat"]];
    for (int i = 0; i<disgustthat.count;i++) {
        NSDictionary *dic = disgustthat[i];
        switch (i) {
            case 0:
                self.labelAmount.text = dic[@"sum"];
                break;
            case 1:
                self.labelLimitDate.text = dic[@"sum"];
                break;
            case 2:
                self.labelDateTip.text = dic[@"outside"];
                self.labelTime.text = dic[@"sum"];
                break;
                
            default:
                break;
        }
    }
    self.labelName.text = dicInfo[@"noise"];
    self.labelStatus.text = dicInfo[@"furry"];
    
    if(!CHStringIsEmpty(dicInfo[@"cangive"])){
        self.buttonAgreem.hidden = NO;
        [self.buttonAgreem setTitle:dicInfo[@"answers"] forState:UIControlStateNormal];
        self.labelLine.hidden = NO;
    }else{
        self.buttonAgreem.hidden = YES;
        self.labelLine.hidden = YES;
    }
}
- (IBAction)clickAgree:(id)sender {
    
//    OrderPopupConfirmViewController *popVC = [[OrderPopupConfirmViewController alloc] init];
//    popVC.url = self.dicInfo[@"cangive"];
//    popVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
//    
    WebViewController *webView = [[WebViewController alloc] init];
    webView.url = self.dicInfo[@"cangive"] ;
    [[UIView xhl_getTopViewController].navigationController pushViewController:webView animated:YES];
    
//    [[UIView xhl_getTopViewController] presentViewController:popVC animated:YES completion:nil];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
